home *** CD-ROM | disk | FTP | other *** search
- Path: news.pge.com!usenet
- From: psk3@pge.com (Phillip Knight)
- Newsgroups: comp.lang.c++
- Subject: Re: overiding c++ stream classes anyone?
- Date: 23 Jan 1996 02:38:56 GMT
- Organization: Pacific Gas and Electric
- Message-ID: <4e1ho0$5en@news02.comp.pge.com>
- References: <4cqbja$62n@earth.njcc.com> <4e1d5f$5en@news02.comp.pge.com>
- NNTP-Posting-Host: psk3ws04.comp.pge.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.6
-
- In article <4e1d5f$5en@news02.comp.pge.com>, psk3@pge.com▌ says...
- >
- >I have pulled the last hair out of my head and still have not solved this
- >problem:
- >
- > class X : public ostream {
- > public:
- > ...
- > X& operator<<(X& (*f)(X&)) { return (*f)(*this); }
- > };
- >
- >
- > X& newl(X& os) {
- > cerr << "this never gets printed" << endl;
- > }
- >
- > main() {
- > X foo;
- > foo << "test one";
- > foo << endl;
- >
- > foo << "test two" << endl;
- > }
- >
- >so the problem is simple: how do i get my manipulator newl to be called? This
- >program as stands does not compile, because inclusion of the operator '<<'
- >(used in order to execute the manipulator) causes class X to no longer
- >recognize the base class operators (it only recognizes X's operator <<).
- >taking the operator out of the class and into the code as a function doesn't
- >solve the problem either as newl never gets called.
- >
-
- well, i got this to work using a friend, but the question still remains: why
- does declaring any type of "operator<<" cause the base classes operators to be
- effectivily hidden? not that i need to do this anymore, but just wondering...
-
- thanks again!
- Phil Knight
- psk3@pge.com
- >
-
-